home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
vdl020d.zip
/
VMATH.DOC
< prev
next >
Wrap
Text File
|
1993-04-14
|
80KB
|
4,006 lines
{
════════════════════════════════════════════════════════════════════════════
Visionix Math Functions Unit (VMATH)
Copyright 1991,92,93 Visionix
ALL RIGHTS RESERVED
────────────────────────────────────────────────────────────────────────────
Revision history in reverse chronological order:
Initials Date Comment
-------- -------- --------------------------------------------------------
mep 03/25/93 Fixed ArcSin, ArcCos, ArcCsc, ArcSec, ArcCot, and
Factorial.
Cleaned up code.
mep 02/11/93 Cleaned up code for beta release
jrt 02/08/93 Sync with beta 0.12
mep 02/02/93 Changed hyberbolic function names to be more proper.
Cleanup of code for release (with more notes).
Added: DistanceXY, QuadraticPlus, QuadraticNeg,
Factorial, Permu, Combo, DegToRad, GradToRad,
DegToGrad, RadToDeg, RadToGrad, GradToDeg, GCF,
LCM.
lpg 01/13/92 Added: Sin2,Cos2
Also wrote up quick Trig Info for header
lpg 01/13/92 Renamed Clamp functions to Range
jrt 12/07/92 Sync with beta 0.11 release
jrt 11/21/92 Sync with beta 0.08
lpg 11/08/92 Added more function: all Hyp and Arc series.
lpg 10/05/92 First logged revision.
----------------------------------------------------------------------------
Caveats/Known Bugs
The following Functions are incomplete and simply return Zero:
ArcCsc, ArcSec and ArcCot
Data was not available at this time to complete these.
----------------------------------------------------------------------------
════════════════════════════════════════════════════════════════════════════
}
(*
Definitions of Terms
--------------------
TRIGONOMETRY - The branch of mathematics that deals with the relations
between the sides and angles of pnae of spherical triangles, and the
calculations based upon them. [<NL trigonometria, lit., "triangle
measuring"]
RADIAN - An angle at the center of a circle, subtending an arc of
the circle equal in length to the radius. A length of the circle's
radius measured across a circle's circumference and measured in
angles from the circle's center. 1 Radian = 57.2958 degrees.
3.14159 Radians = 360 degrees. [Radi(us) + an]
HYPOTENUSE - The side of a right triangle opposite the right angle.
QUADRANT - A quarter of a circle. [ME<L quadrant-(s. of quadrans)
4th part]
e (base of the natural logarithms) is approximately 2.718;
π (pi) is approximately 3.14159
Θ = Angle Theta (General reference angle)
∞ = Infinity
│x│ = Absolute value of x
√x = Square root of x
x^n = x raised to the n power
ln(x) = Natural logarithm of x
GRAPHS OF THE UNIT CIRCLE
=========================
I. QUADRANT SYSTEM
------------------
R = Radius of Circle (here 1 unit)
+Y
.
.
.(0,1)
.....*......
.. . .. B
. . +
Quadrant 2 . . /|. Quadrant 1
. . / | .
. . / | .
. . R / | .
. . / a| .
. . / c | .
. . / | .
(-1,0). A./ b |C .(1,0)
-X ......*............+--------+....*..... +X
. (0,0). .
. Origin. .
. . .
. . .
. . .
. . .
. . .
Quadrant 3 . . . Quadrant 4
. . .
.. . ..
.....*.....
.(0,-1)
.
.
-Y
II. RADIANS AND DEGREES
-----------------------
π/2
2π/3 π/3
....*....
3π/4 ..* *.. π/4
. .
* 90 *
. 120 . 60 .
. . .
5π/6 . 135 . 45 . π/6
* . *
. 150 . 30 .
. . .
. . .
. . .
π * 180 .......+......... 0 * 0
. . .
. . .
. . .
. 210 . 330 .
* . *
7π/6 . . . 11π/6
. 225 . 315 .
. . .
* 240 300 *
. 270 .
5π/4 .. .. 7π/4
*....*....*
4π/3 5π/3
3π/2
III. CIRCULAR FUNCTION DEFINITIONS
----------------------------------
Y
.
.
.........
(x,y)... ...
. . .
* . .
.|\ . .
. | \ r . .
. | \ . . Where Θ is any angle:
. | \ .
. y| \ __ . sin Θ = y / r
. | \ / \ .
. | \ Θ \ . cos Θ = x / r
. | \ | .
.. . ..---------+ .......... . ..X tan Θ = y / x
. x .
. . . csc Θ = r / y
. . .
. . . sec Θ = r / x
. . .
. . . cot Θ = x / y
. . .
. . .
. . .
. . .
.. ..
...........
.
.
IV. SINE/COSINE RELATIONSHIPS
-----------------------------
On unit circles, (x, y) = (cos, sin)
(0, 1)
.
(-1/2, √3/2) . (1/2, √3/2)
....*....
(-√2/2, √2/2) ..* *.. (√2/2, √2/2)
. . .
* . *
. . .
(√3/2, 1/2) . . . (√3/2, 1/2)
. . .
* . *
. II . I .
. . .
. . .
. . .
(-1, 0) ..... * ...........+........... * ..... (1, 0)
. . .
. . .
. . .
. . .
* III . IV *
. . .
(-√3/2, -1/2) . . . (√3/2, -1/2)
. . .
* . *
. . .
(-√2/2, -√2/2) .. .. (√2/2, -√2/2)
*....*....*
(-1/2, -√3/2) . (1/2, -√3/2)
.
(0, -1)
In quadrant I, ALL trig. functions are positive.
In quadrant II, only SIN and CSC are positive.
In quadrant III, only TAN and COT are positive.
In quadrant IV, only COS and SEC are positive.
Definition of the Six Trigonometric Functions
---------------------------------------------
(Right triangle definitions, where 0 < Θ < π/2)
e
s + sin Θ = Opp / Hyp
u /|O
n / |p cos Θ = Adj / Hyp
e / |p
t / |o tan Θ = Opp / Adj
o / |s
p / |i csc Θ = 1 / sin Θ = Hyp / Opp
y / |t
H / Θ |e sec Θ = 1 / cos Θ = Hyp / Adj
+--------+
Adjacent cot Θ = 1 / tan Θ = Adj / Opp
Definition of Inverse Trigonometric Functions
---------------------------------------------
Function Domain Range
-------------------------- ------------ ----------------
y = arcsin x iff sin y = x -1 <= x <= 1 -π/2 <= y <= π/2
y = arccos x iff cos y = x -1 <= x <= 1 0 <= y <= π
y = arctan x iff tan y = x -∞ < x < ∞ -π/2 < y < π/2
y = arccot x iff cot y = x -∞ < x < ∞ 0 < y < π
y = arcsec x iff sec y = x │x│ >= 1 0 <= y <= π, y <> π/2
y = arccsc x iff csc y = x │x│ >= 1 -π/2 <= y <= π/2, y <> 0
Definition of the Hyberbolic Functions
--------------------------------------
Function Domain Range
------------------------- ------------------ ------------------
sinh x = (e^x - e^-x) / 2 -∞ < x < ∞ -∞ < y < ∞
cosh x = (e^x + e^-x) / 2 -∞ < x < ∞ -1 <= y < ∞
tanh x = sinh x / cosh x -∞ < x < ∞ -1 < y < 1
csch x = 1 / sinh x, -∞ < x < ∞, x <> 0 -∞ < y < ∞, y <> 0
sech x = 1 / cosh x -∞ < x < ∞ 0 < y <= 1
coth x = 1 / tanh x, -∞ < x < ∞, x <> 0 -∞ < y < -1,
1 < y < ∞
Definition of the Inverse Hyperbolic Functions
----------------------------------------------
Function Domain Range
------------------------------------------- ---------- ---------
arcsinh x = ln( x + √(x^2 + 1) ) -∞ < x < ∞ -∞ < y < ∞
arccosh x = ln( x + √(x^2 - 1) ) 1 <= x < ∞ ∞ <= y < ∞
arctanh x = (1/2) * ln( (1 + x) / (1 - x) ) │x│ < 1 ∞ <= y < ∞
arccoth x = (1/2) * ln( (x + 1) / (x - 1) ) │x│ > 1 -∞ < y < ∞, y <> 0
arcsech x = ln( (1 + √(1 - x^2)) / x ) 0 < x <= 1 0 <= y < ∞
arccsch x = ln( (1 + √(1 + x^2)) / │x│ ) x > 0 -∞ < y < ∞, y <> 0
= ln( (-1 + √(1 + x^2)) / │x│ ) x < 0
*)
{────────────────────────────────────────────────────────────────────────────}
Unit VMath;
{------------------------------------}
{ Constants and type definitions }
{------------------------------------}
Const
cINFINITY = 9.9999999999E+37; {or 5.5E11, also 65000 for INTEGER}
cOVERFLOW = 9.9999999999E+37;
cUNDERFLOW = 1.0E-37;
cTolerance = 0.00000001; {for math error tolerances}
TYPE
{ Linear Array }
TArrayR = ARRAY[1..1] of REAL;
PArrayR = ^TArrayR;
TArrayRA = ARRAY[1..100] of REAL;
PArrayRA = ^TArrayRA;
{ Coordinate Array - Maps over Linear Array }
TRec2R = RECORD
X : REAL;
Y : REAL;
END;
TArray2R = Array[1..1] of TRec2R;
PArray2R = ^TArray2R;
TArray2RA = Array[1..100] of TRec2R;
PArray2RA = ^TArray2RA;
{------------------------------------}
{ Procedure and function definitions }
{------------------------------------}
{-------------------}
{ Type Converstions }
{-------------------}
Function HMStoDegrees( Degs : WORD;
Mins : WORD;
Secs : REAL ) : REAL;
Procedure DegreesToHMS( Degrees : REAL;
Var Degs : INTEGER;
Var Min : INTEGER;
Var Sec : REAL );
Function DegToRad( Deg : REAL ) : REAL;
Function GradToRad( Grad : REAL ) : REAL;
Function DegToGrad( Deg : REAL ) : REAL;
Function RadToDeg( Rad : REAL ) : REAL;
Function RadToGrad( Rad : REAL ) : REAL;
Function GradToDeg( Grad : REAL ) : REAL;
{----------------}
{ Trig Functions }
{----------------}
Function Quad( Radians : REAL ) : INTEGER;
Function Quad2( X, Y : REAL ) : INTEGER;
Function Sin2( X, Y : REAL ) : REAL;
Function Cos2( X, Y : REAL ) : REAL;
Function Tan( X : REAL ) : REAL;
Function Tan2( X, Y : REAL ) : REAL;
Function Cot( X : REAL ) : REAL;
Function Cot2( X, Y : REAL ) : REAL;
Function Csc( X : REAL ) : REAL;
Function Sec( X : REAL ) : REAL;
Function Sinh( X : REAL ) : REAL; {NOT TESTED}
Function Cosh( X : REAL ) : REAL;
Function Tanh( X : REAL ) : REAL;
Function Csch( X : REAL ) : REAL; {NOT TESTED}
Function Sech( X : REAL ) : REAL; {NOT TESTED}
Function Coth( X : REAL ) : REAL; {NOT TESTED}
Function ArcSin( X : REAL ) : REAL;
Function ArcSin2( X : REAL;
Quadrant : INTEGER ) : REAL;
Function ArcCos( X : REAL ) : REAL;
Function ArcCos2( X : REAL;
Quadrant : INTEGER ) : REAL;
Function ArcTan1( X : REAL ) : REAL;
Function ArcTan2( X, Y : REAL ) : REAL;
Function ArcCsc( X : REAL ) : REAL; {NOT TESTED}
Function ArcSec( X : REAL ) : REAL; {NOT TESTED}
Function ArcCot( X : REAL ) : REAL; {NOT TESTED}
Function ArcSinh( X : REAL ) : REAL;
Function ArcCosh( X : REAL ) : REAL;
Function ArcTanh( X : REAL ) : REAL;
Function ArcCsch( X : REAL ) : REAL;
Function ArcSech( X : REAL ) : REAL;
Function ArcCoth( X : REAL ) : REAL;
{----------------------}
{ Basic Math Functions }
{----------------------}
Function Power( Num : LONGINT;
Exponent : LONGINT ) : LONGINT;
Function PowerR( Num : REAL;
Exponent : REAL ) : REAL;
Function Root( Num : LONGINT;
RootVal : LONGINT ) : LONGINT;
Function RootR( Num : REAL;
RootVal : REAL ) : REAL;
Function Log( Num : REAL;
Base : REAL ) : REAL;
Function FastHyp( XDist : REAL;
YDist : REAL ) : REAL;
Function FastHypR( XDist : REAL;
YDist : REAL ) : REAL;
Function Hypot( XDist : REAL;
YDist : REAL ) : REAL;
Function FastDist( X1 : LONGINT;
Y1 : LONGINT;
X2 : LONGINT;
Y2 : LONGINT ) : LONGINT;
Function DistanceXY( X1 : REAL;
Y1 : REAL;
X2 : REAL;
Y2 : REAL ) : REAL;
Function Percent( Part : LONGINT;
Whole : LONGINT ) : REAL;
Function Min( A : LONGINT;
B : LONGINT ) : LONGINT;
Function MinR( A : REAL;
B : REAL ) : REAL;
Function Max( A : LONGINT;
B : LONGINT ) : LONGINT;
Function MaxR( A : REAL;
B : REAL ) : REAL;
Function Range( Num : LONGINT;
Low : LONGINT;
High : LONGINT ) : LONGINT;
Function RangeR( Num : REAL;
Low : REAL;
High : REAL ) : REAL;
Function Floor( Num : LONGINT;
Low : LONGINT ) : LONGINT;
Function FloorR( Num : REAL;
Low : REAL ) : REAL;
Function Ceiling( Num : LONGINT;
High : LONGINT ) : LONGINT;
Function CeilingR( Num : REAL;
High : REAL ) : REAL;
Function Sign( Num : LONGINT ) : INTEGER;
Function SignR( Num : REAL ) : INTEGER;
{-----------------------}
{ Higher Math Functions }
{-----------------------}
Function QuadraticPlus( A : LONGINT;
B : LONGINT;
C : LONGINT ) : REAL;
Function QuadraticNeg( A : LONGINT;
B : LONGINT;
C : LONGINT ) : REAL;
Function Factorial( N : BYTE ) : REAL;
Function Permu( N : BYTE;
R : BYTE ) : REAL;
Function Combo( N : BYTE;
R : BYTE ) : REAL;
Function Prime( N : LONGINT ) : BOOLEAN;
Function GCF( A : LONGINT;
B : LONGINT ) : LONGINT;
Function LCM( A : LONGINT;
B : LONGINT ) : LONGINT;
Procedure LoadArrayR( VAR Arr : PArrayR;
Idx : WORD;
R : REAL );
Procedure LoadArrayRXY( VAR Arr : PArray2R;
Idx : WORD;
X : REAL;
Y : REAL );
Procedure MeanStdDev( Arr : PArrayR;
Cnt : INTEGER;
VAR Mean : REAL;
VAR StdDev : REAL );
Function Sigma( Arr : PArrayR;
Cnt : INTEGER ) : REAL;
Procedure LeastSqr( Arr : PArray2R;
Cnt : INTEGER;
VAR YInt : REAL;
VAR Slope : REAL );
{------------------------------}
{ Begin implementation of code }
{------------------------------}
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function HMStoDegrees( Degs : WORD;
Mins : WORD;
Secs : REAL ) : REAL;
[PARAMETERS]
Degs Arc Degrees
Mins Arc Minutes
Secs Arc Seconds
[RETURNS]
Floating Point Decimal Degrees
[DESCRIPTION]
Converts Arc Degrees, Minutes and Seconds into a Floating Point
Degree Value.
[SEE-ALSO]
DegreesToHMS
[EXAMPLE]
BEGIN
WriteLn( HMStoDegrees( 59, 30, 0 ):8:4 );
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure DegreesToHMS( Degrees : REAL;
Var Degs : INTEGER;
Var Min : INTEGER;
Var Sec : REAL );
[PARAMETERS]
Degrees Floating Point Angle in Degrees
Degs VAR Returned Arc Degrees
Min VAR Returned Arc Minutes
Sec VAR Returned Arc Seconds
[RETURNS]
(Function : None)
(VAR : [Degs] Arc Degrees)
(VAR : [Min ] Arc Minutes)
(VAR : [Sec ] Arc Seconds)
[DESCRIPTION]
Converts a Floating Point Angle in Degrees into the Component
Parts of Arc (Degrees, Minutes and Seconds)
[SEE-ALSO]
[EXAMPLE]
VAR
D,M,S : REAL;
BEGIN
DegreesToHMS( 45.6137, D,M,S );
WriteLn( 'Deg = ',Deg:2:0 );
WriteLn( 'Min = ',Min:2:0 );
WriteLn( 'Sec = ',Sec:5:2 );
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function DegToRad( Deg : REAL ) : REAL;
[PARAMETERS]
Deg Floating Point Angle in Degrees
[RETURNS]
Angle in Radians
[DESCRIPTION]
Converts Arc Degrees to Radians.
[SEE-ALSO]
DegToGrad
RadToDeg
RadToGrad
GradToDeg
GradToRad
[EXAMPLE]
VAR
Rad : REAL;
BEGIN
Rad := DegToRad( 0.0 ); { Rad = 0.0000 }
Rad := DegToRad( 30.0 ); { Rad = 0.5236 }
Rad := DegToRad( 45.0 ); { Rad = 0.7854 }
Rad := DegToRad( 90.0 ); { Rad = 1.5708 }
Rad := DegToRad( 180.0 ); { Rad = 3.1416 }
Rad := DegToRad( 360.0 ); { Rad = 6.2832 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function DegToGrad( Deg : REAL ) : REAL;
[PARAMETERS]
Deg Angle in Degrees
[RETURNS]
Angle in Gradients
[DESCRIPTION]
Converts Arc Degrees to Gradients
[SEE-ALSO]
DegToRad
RadToDeg
RadToGrad
GradToDeg
GradToRad
[EXAMPLE]
VAR
Grad : REAL;
BEGIN
Grad := DegToGrad( 0.0 ); { Grad = 0.0000 }
Grad := DegToGrad( 30.0 ); { Grad = 33.3333 }
Grad := DegToGrad( 45.0 ); { Grad = 50.0000 }
Grad := DegToGrad( 90.0 ); { Grad = 100.0000 }
Grad := DegToGrad( 180.0 ); { Grad = 200.0000 }
Grad := DegToGrad( 360.0 ); { Grad = 400.0000 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function RadToDeg( Rad : REAL ) : REAL;
[PARAMETERS]
Rad Angle in Radians
[RETURNS]
Angle in Degrees
[DESCRIPTION]
Converts Arc Radians to Degrees
[SEE-ALSO]
DegToRad
DegToGrad
RadToGrad
GradToDeg
GradToRad
[EXAMPLE]
VAR
Deg : REAL;
BEGIN
Deg := RadToDeg( 0.0 ); { Deg = 0.0000 }
Deg := RadToDeg( PI/6.0 ); { Deg = 30.0000 }
Deg := RadToDeg( PI*0.25); { Deg = 45.0000 }
Deg := RadToDeg( PI*0.5 ); { Deg = 90.0000 }
Deg := RadToDeg( PI ); { Deg = 180.0000 }
Deg := RadToDeg( PI*2.0 ); { Deg = 360.0000 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function RadToGrad( Rad : REAL ) : REAL;
[PARAMETERS]
Rad Angle in Radians
[RETURNS]
Angle in Gradients
[DESCRIPTION]
Converts Arc Radians to Gradients
[SEE-ALSO]
DegToRad
DegToGrad
RadToDeg
GradToDeg
GradToRad
[EXAMPLE]
VAR
Grad : REAL;
BEGIN
Grad := RadToGrad( 0.0 ); { Grad = 0.0000 }
Grad := RadToGrad( PI/6.0 ); { Grad = 33.3333 }
Grad := RadToGrad( PI*0.25); { Grad = 50.0000 }
Grad := RadToGrad( PI*0.5 ); { Grad = 100.0000 }
Grad := RadToGrad( PI ); { Grad = 200.0000 }
Grad := RadToGrad( 2.0*PI ); { Grad = 400.0000 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function GradToDeg( Grad : REAL ) : REAL;
[PARAMETERS]
Grad Angle in Gradients
[RETURNS]
Arc Degrees
[DESCRIPTION]
Converts Arc Gradients to Degrees
[SEE-ALSO]
DegToRad
DegToGrad
RadToDeg
RadToGrad
GradToRad
[EXAMPLE]
VAR
Deg : REAL;
BEGIN
Deg := GradToDeg( 0.0 ); { Deg = 0.0000 }
Deg := GradToDeg( 30.0d); { Deg = 30.0000 }
Deg := GradToDeg( 50.0 ); { Deg = 45.0000 }
Deg := GradToDeg( 100.0 ); { Deg = 90.0000 }
Deg := GradToDeg( 200.0 ); { Deg = 180.0000 }
Deg := GradToDeg( 400.0 ); { Deg = 360.0000 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function GradToRad( Grad : REAL ) : REAL;
[PARAMETERS]
Grad Angle in Gradients
[RETURNS]
Angle in Radians
[DESCRIPTION]
Converts Arc Gradients to Radians
[SEE-ALSO]
DegToRad
DegToGrad
RadToDeg
RadToGrad
GradToDeg
[EXAMPLE]
VAR
Rad : REAL;
BEGIN
Rad := GradToRad( 0.0000 ); { Rad = 0.0000 }
Rad := GradToRad( 33.3333 ); { Rad = 0.5236 }
Rad := GradToRad( 50.0000 ); { Rad = 0.7854 }
Rad := GradToRad( 100.0000 ); { Rad = 1.5708 }
Rad := GradToRad( 200.0000 ); { Rad = 3.1416 }
Rad := GradToRad( 400.0000 ); { Rad = 6.2832 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Quad( Radians : REAL ) : INTEGER;
[PARAMETERS]
Radians Angle in Radians
[RETURNS]
Quadrant in which the Radians is contained
[DESCRIPTION]
Determines which Quadrant is the Radian Angle falls in
There are 4 Quadrants as follows:
Quadrant I - 0 deg to 90 deg
Quadrant II - 91 deg to 180 deg
Quadrant III - 181 deg to 270 deg
Quadrant IV - 271 deg to 359 deg
[SEE-ALSO]
Quad2
[EXAMPLE]
VAR
Q : INTEGER;
BEGIN
Q := Quad( DegToRad( 0.0 ) ); { Q = 1 }
Q := Quad( DegToRad( 45.0 ) ); { Q = 1 }
Q := Quad( DegToRad( 90.0 ) ); { Q = 1 }
Q := Quad( DegToRad( 135.0 ) ); { Q = 2 }
Q := Quad( DegToRad( 210.0 ) ); { Q = 3 }
Q := Quad( DegToRad( 300.0 ) ); { Q = 4 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Quad2( X, Y : REAL ) : INTEGER;
[PARAMETERS]
X X Coordinate Value
Y Y Coordinate Value
[RETURNS]
Returns the Quadrant corresponding to the X and Y Values.
[DESCRIPTION]
Determines which Quadrant corresponds to the Coordinate X,Y
[SEE-ALSO]
Quad
[EXAMPLE]
VAR
Q : INTEGER;
BEGIN
Q := Quad2( 1.0, 0.0 ); { Q = 1 }
Q := Quad2( 1.0, 1.0 ); { Q = 1 }
Q := Quad2( 0.0, 1.0 ); { Q = 1 }
Q := Quad2( -1.0, 1.0 ); { Q = 2 }
Q := Quad2( -1.0, -1.0 ); { Q = 3 }
Q := Quad2( 1.0, -1.0 ); { Q = 4 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Sin2( X,Y : REAL ) : REAL;
[PARAMETERS]
X X Coordinate Value
Y Y Coordinate Value
[RETURNS]
Sine of the Angle created by Coordinate X,Y
[DESCRIPTION]
Determines and returns the Sine of the Angle computed from
the Coordinate X,Y
[SEE-ALSO]
Cos2 Sinh ArcSin ArcSinh
Tan Cosh ArcSin2 ArcCosh
Tan2 Tanh ArcCos ArcTanh
Cot ArcCos2 ArcCsch
Cot2 ArcTan1 ArcSech
Csc ArcTan2 ArcCoth
Sec ArcCsc
ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
BEGIN
For i := 0 to 100 Do
WriteLn( 'Sin2(1,',i,') = ',Sin2( 1.0, i ) :8:4 );
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Cos2( X,Y : REAL ) : REAL;
[PARAMETERS]
X X Coordinate Value
Y Y Coordinate Value
[RETURNS]
CoSine of Angle created by Coordinate X,Y
[DESCRIPTION]
Determines and returns the CoSine of the Angle computed from
the Coordinate X,Y
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Tan Cosh ArcSin2 ArcCosh
Tan2 Tanh ArcCos ArcTanh
Cot ArcCos2 ArcCsch
Cot2 ArcTan1 ArcSech
Csc ArcTan2 ArcCoth
Sec ArcCsc
ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
BEGIN
For i := 0 to 100 Do
WriteLn( 'Cos2(1,',i,') = ',Cos2( 1.0, i ) :8:4 );
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Tan( X : REAL ) : REAL;
[PARAMETERS]
X Angle in Radians
[RETURNS]
Returns the Tangent of the Angle
[DESCRIPTION]
Computes and returns the Tangent of the given Angle. Replaces
Std Pascal "Tan" as handles range checking and bounds.
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan2 Tanh ArcCos ArcTanh
Cot ArcCos2 ArcCsch
Cot2 ArcTan1 ArcSech
Csc ArcTan2 ArcCoth
Sec ArcCsc
ArcSec
ArcCot
[EXAMPLE]
VAR
R : REAL;
I : INTEGER;
BEGIN
R := 0.0;
For i := 0 to 100 Do
BEGIN
WriteLn( 'Tan(',R:0:0,') = ',Tan( R ) :8:4 );
R := R + 1.0;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Tan2( X, Y : REAL ) : REAL;
[PARAMETERS]
X X Coordinate Value
Y Y Coordinate Value
[RETURNS]
Tangent of the Angle created by Coordinate X,Y
[DESCRIPTION]
Computes and returns the Tangent of the Angle computed from
the Coordinate X,Y
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Cot ArcCos2 ArcCsch
Cot2 ArcTan1 ArcSech
Csc ArcTan2 ArcCoth
Sec ArcCsc
ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
BEGIN
For i := 0 to 100 Do
WriteLn( 'Tan2(1,',i,') = ',Tan2( 1.0, i ) :8:4 );
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Cot( X : REAL ) : REAL;
[PARAMETERS]
X Angle in Radians
[RETURNS]
CoTangent of the Angle
[DESCRIPTION]
Conputes and returns the CoTangent of a given Angle.
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot2 ArcTan1 ArcSech
Csc ArcTan2 ArcCoth
Sec ArcCsc
ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 0.0;
For i := 0 to 100 Do
BEGIN
WriteLn( 'Cot(',R:0:0,') = ',Cot( 1.0, i ) :8:4 );
R := R + 1.0;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Cot2( X, Y : REAL ) : REAL;
[PARAMETERS]
X X Coordinate Value
Y Y Coordinate Value
[RETURNS]
CoTangent of Angle computed from Coordinate X,Y
[DESCRIPTION]
Computes and returns the CoTangent of an Angle computed from
the Coordinate X,Y
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Csc ArcTan2 ArcCoth
Sec ArcCsc
ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
BEGIN
For i := 0 to 100 Do
WriteLn( 'Cot2(1,',i,') = ',Cot2( 1.0, i ) :8:4 );
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Csc( X : REAL ) : REAL;
[PARAMETERS]
X Angle in Radians
[RETURNS]
CoSecant of Angle
[DESCRIPTION]
Computes and returns the CoSecant of a given Angle
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Cot2 ArcTan2 ArcCoth
Sec ArcCsc
ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 0.0;
For i := 0 to 100 Do
BEGIN
WriteLn( 'Csc(',R:0:0,') = ',Csc( R ) :8:4 );
R := R + 1.0;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Sec( X : REAL ) : REAL;
[PARAMETERS]
X Angle in Radians
[RETURNS]
Secant of Angle
[DESCRIPTION]
Computes and returns the Secant of a given Angle
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Cot2 ArcTan2 ArcCoth
Csc ArcCsc
ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 0.0;
For i := 0 to 100 Do
BEGIN
WriteLn( 'Sec(',R:0:0,') = ',Sec( R ) :8:4 );
R := R + 1.0;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Sinh( X : REAL ) : REAL; {NOT TESTED}
[PARAMETERS]
X Angle in Radians
[RETURNS]
Hyperbolic Sine of Angle
[DESCRIPTION]
Computes and returns the Hyperbolic Sine of a given Angle
[SEE-ALSO]
Sin2 Cosh ArcSin ArcSinh
Cos2 Tanh ArcSin2 ArcCosh
Tan ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Cot2 ArcTan2 ArcCoth
Csc ArcCsc
Sec ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 0.0;
For i := 0 to 100 Do
BEGIN
WriteLn( 'Sinh(',R:0:0,') = ',Sinh( R ) :8:4 );
R := R + 1.0;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Cosh( X : REAL ) : REAL;
[PARAMETERS]
X Angle in Radians
[RETURNS]
Hyperbolic CoSine of Angle
[DESCRIPTION]
Computes and returns the Hyperbolic CoSine of a given Angle
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Tanh ArcSin2 ArcCosh
Tan ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Cot2 ArcTan2 ArcCoth
Csc ArcCsc
Sec ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 0.0;
For i := 0 to 100 Do
BEGIN
WriteLn( 'Cosh(',R:0:0,') = ',Cosh( R ) :8:4 );
R := R + 1.0;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Tanh( X : REAL ) : REAL;
[PARAMETERS]
X Angle in Radians
[RETURNS]
Hyperbolic Tangent of Angle
[DESCRIPTION]
Computes and returns the Hyperbolic Tangent of a given Angle
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Cot2 ArcTan2 ArcCoth
Csc ArcCsc
Sec ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 0.0;
For i := 0 to 100 Do
BEGIN
WriteLn( 'Tanh(',R:0:0,') = ',Tanh( R ) :8:4 );
R := R + 1.0;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Csch( X : REAL ) : REAL; {NOT TESTED}
[PARAMETERS]
X Angle in Radians
[RETURNS]
Hyperbolic Cosecant of Angle
[DESCRIPTION]
Computes and returns the Hyperbolic Cosecant of a given Angle
[SEE-ALSO]
Sin2 Cosh ArcSin ArcSinh
Cos2 Tanh ArcSin2 ArcCosh
Tan ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Cot2 ArcTan2 ArcCoth
Csc ArcCsc
Sec ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 0.0;
For i := 0 to 100 Do
BEGIN
WriteLn( 'Csch(',R:0:0,') = ',Csch( R ) :8:4 );
R := R + 1.0;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Sech( X : REAL ) : REAL;
[PARAMETERS]
X Angle in Radians
[RETURNS]
Hyperbolic Secant of Angle
[DESCRIPTION]
Computes and returns the Hyperbolic Secant of a given Angle
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Tanh ArcSin2 ArcCosh
Tan ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Cot2 ArcTan2 ArcCoth
Csc ArcCsc
Sec ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 0.0;
For i := 0 to 100 Do
BEGIN
WriteLn( 'Sech(',R:0:0,') = ',Sech( R ) :8:4 );
R := R + 1.0;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Coth( X : REAL ) : REAL;
[PARAMETERS]
X Angle in Radians
[RETURNS]
Hyperbolic Cotangent of Angle
[DESCRIPTION]
Computes and returns the Hyperbolic Cotangent of a given Angle
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Cot2 ArcTan2 ArcCoth
Csc ArcCsc
Sec ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 0.0;
For i := 0 to 100 Do
BEGIN
WriteLn( 'Coth(',R:0:0,') = ',Coth( R ) :8:4 );
R := R + 1.0;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcSin( X : REAL ) : REAL;
[PARAMETERS]
X Sine Value
[RETURNS]
Angle in radians whose sine is X.
[DESCRIPTION]
Computes and returns the Inverse sine of a given value.
Positive sine values are assumed quadrant 1 and negative sine
values are assumed as quadrant 4 as there is no means to
compute an absolute angle based on the simple sine value.
NOTE: Sine Value is NOT Range Checked and MUST be in Bounds.
[SEE-ALSO]
Sin2 Sinh ArcSin2 ArcSinh
Cos2 Cosh ArcCos ArcCosh
Tan Tanh ArcCos2 ArcTanh
Tan2 ArcTan1 ArcCsch
Cot ArcTan2 ArcSech
Cot2 ArcCsc ArcCoth
Csc ArcSec
Sec ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcSin(',R:0:0,') = ',ArcSin( R ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcSin2( X : REAL;
Quadrant : INTEGER ) : REAL;
[PARAMETERS]
X Sine Value
Quadrant Angular Quadrant Containing Sine Value
[RETURNS]
Arc Sine Angle of Sine X in Radians.
[DESCRIPTION]
Computes and returns the Arc Sine of a given Sine Value.
Using the input Quadrant, the Correct Absolute Sine Angle
is determined.
NOTE: Sine Value is NOT Range Checked and MUST be in Bounds.
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcCos ArcCosh
Tan Tanh ArcCos2 ArcTanh
Tan2 ArcTan1 ArcCsch
Cot ArcTan2 ArcSech
Cot2 ArcCsc ArcCoth
Csc ArcSec
Sec ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcSin2(',R:0:0,') [Quad=3] = ',ArcSin2( R, 3 ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcCos( X : REAL ) : REAL;
[PARAMETERS]
X CoSine Value
[RETURNS]
Inverse cosine angle in radians.
[DESCRIPTION]
Computes and returns the Arc CoSine of a given CoSine Value.
Positive CoSine Values are assumed Quadrant 1 and negative
CoSine Values are assumed Quadrant 2 as there is no means to
compute Absolute Angle based upon Simple CoSine Value.
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos2 ArcTanh
Tan2 ArcTan1 ArcCsch
Cot ArcTan2 ArcSech
Cot2 ArcCsc ArcCoth
Csc ArcSec
Sec ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcCos(',R:0:0,') = ',ArcCos( R ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcCos2( X : REAL;
Quadrant : INTEGER ) : REAL;
[PARAMETERS]
X CoSine Value
Quadrant Angular Quadrant Containing CoSine Value
[RETURNS]
Arc CoSine Angle of CoSine Value
[DESCRIPTION]
Computes and returns the Arc CoSine of a given CoSine Value.
Using the input Quadrant, the Correct Absolute CoSine Angle
is determined.
NOTE: Cosine Value is NOT Range Checked and MUST be in Bounds.
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Tan2 ArcTan1 ArcCsch
Cot ArcTan2 ArcSech
Cot2 ArcCsc ArcCoth
Csc ArcSec
Sec ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcCos2(',R:0:0,') [Quad=3] = ',ArcCos2( R,3 ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcTan1( X : REAL ) : REAL;
[PARAMETERS]
X Tangent Value
[RETURNS]
Arc Tangent Angle of Tangent X
[DESCRIPTION]
Computes and returns the Arc Tangent of a given Tangent Value.
Positive Tangent Values are assumed Quadrant 1 and negative
Tangent Values are assumed Quadrant 4 as there is no means to
compute Absolute Angle based upon Simple Tangent Value.
NOTE: Limiting Tangent Range is based upon the Constant cINFINITY.
Anything exceeds this in either direction is considered 90 degrees.
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan2 ArcSech
Cot2 ArcCsc ArcCoth
Csc ArcSec
Sec ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcTan1(',R:0:0,') = ',ArcTan1( R ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcTan2( X, Y : REAL ) : REAL;
[PARAMETERS]
X X Coordinate Value
Y Y Coordinate Value
[RETURNS]
Arc Tangent Angle computed from Coordinate X,Y
[DESCRIPTION]
Determines and returns the ArcTangent Angle of a given Tangent
Value computed from the Coordinate X,Y
Borland Pascal has a problem with an Angle in the 4th Quadrant
when the argument becomes negative. The Negative argument table
has not been uniformly prepared. This function handles that
problem.
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Cot2 ArcCsc ArcCoth
Csc ArcSec
Sec ArcCot
[EXAMPLE]
VAR
I : INTEGER;
BEGIN
For i := 100 DownTo 0 Do
WriteLn( 'ArcTan2(1,',i,') = ',ArcTan2( 1, i ) :8:4 );
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcCsc( X : REAL ) : REAL;
[PARAMETERS]
X CoSecant Value
[RETURNS]
Inverse cosecant angle in radians.
[DESCRIPTION]
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Cot2 ArcTan2 ArcCoth
Csc ArcSec
Sec ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcCsc(',R:0:0,') = ',ArcCsc( R ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcSec( X : REAL ) : REAL;
[PARAMETERS]
X Secant Value
[RETURNS]
Inverse secant angle in radians.
[DESCRIPTION]
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Cot2 ArcTan2 ArcCoth
Csc ArcCsc
Sec ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcSec(',R:0:0,') = ',ArcSec( R ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcCot( X : REAL ) : REAL;
[PARAMETERS]
X CoTangent Value
[RETURNS]
Inverse cotangent angle in radians.
[DESCRIPTION]
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Cot2 ArcTan2 ArcCoth
Csc ArcCsc
Sec ArcSec
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcCot(',R:0:0,') = ',ArcCot( R ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcSinh( X : REAL ) : REAL;
[PARAMETERS]
X Hyperbolic Sine Value
[RETURNS]
Arc Hyperbolic Sine Angle
[DESCRIPTION]
Computes and returns the Arc Hyperbolic Sine Angle of a given
Hyperbolic Sine Angle.
NOTE: The Hyperbolic Sine Value is NOT Range Checked and MUST
be in Bounds.
[SEE-ALSO]
Sin2 Sinh ArcSin ArcCosh
Cos2 Cosh ArcSin2 ArcTanh
Tan Tanh ArcCos ArcCsch
Tan2 ArcCos2 ArcSech
Cot ArcTan1 ArcCoth
Cot2 ArcTan2
Csc ArcCsc
Sec ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcSinh(',R:0:0,') = ',ArcSinh( R ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcCosh( X : REAL ) : REAL;
[PARAMETERS]
X Hyperbolic CoSine Value
[RETURNS]
Arc Hyperbolic CoSine Angle
[DESCRIPTION]
Computes and returns the Arc Hyperbolic CoSine Angle of a given
Hyperbolic CoSine Value.
NOTE: The Hyperbolic CoSine Value is NOT Range Checked and MUST
be in Bounds.
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcTanh
Tan Tanh ArcCos ArcCsch
Tan2 ArcCos2 ArcSech
Cot ArcTan1 ArcCoth
Cot2 ArcTan2
Csc ArcCsc
Sec ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcCosh(',R:0:0,') = ',ArcCosh( R ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcTanh( X : REAL ) : REAL;
[PARAMETERS]
X Hyperbolic Tangent Value
[RETURNS]
Arc Hyperbolic Tangent Angle
[DESCRIPTION]
Computes and returns the Arc Hyperbolic Tangent Angle of a given
Hyperbolic Tangent Value.
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcCsch
Tan2 ArcCos2 ArcSech
Cot ArcTan1 ArcCoth
Cot2 ArcTan2
Csc ArcCsc
Sec ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcTanh(',R:0:0,') = ',ArcTanh( R ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcCsch( X : REAL ) : REAL;
[PARAMETERS]
X Hyperbolic CoSecant Value
[RETURNS]
Arc Hyperbolic CoSecant Angle
[DESCRIPTION]
Computes and returns the Arc Hyperbolic CoSecant Angle of a given
Hyperbolic CoSecant Value.
NOTE: The Hyperbolic CoSecant Value is NOT Range Checked and MUST
be in Bounds.
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Tan2 ArcCos2 ArcSech
Cot ArcTan1 ArcCoth
Cot2 ArcTan2
Csc ArcCsc
Sec ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcCsch(',R:0:0,') = ',ArcCsch( R ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcSech( X : REAL ) : REAL;
[PARAMETERS]
X Hyperbolic Secant Value
[RETURNS]
Arc Hyperbolic Secant Angle
[DESCRIPTION]
Computes and returns the Arc Hyperbolic Secant Angle of a given
Hyperbolic Secant Value.
NOTE: The Hyperbolic Secant Value is NOT Range Checked and MUST
be in Bounds.
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcCoth
Cot2 ArcTan2
Csc ArcCsc
Sec ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcSech(',R:0:0,') = ',ArcSech( R ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function ArcCoth( X : REAL ) : REAL;
[PARAMETERS]
X Hyperbolic Tangent Value
[RETURNS]
Arc Hyperbolic Tangent Angle
[DESCRIPTION]
Computes and returns the Arc Hyperbolic Tangent Angle of a given
Hyperbolic Tangent Value.
[SEE-ALSO]
Sin2 Sinh ArcSin ArcSinh
Cos2 Cosh ArcSin2 ArcCosh
Tan Tanh ArcCos ArcTanh
Tan2 ArcCos2 ArcCsch
Cot ArcTan1 ArcSech
Cot2 ArcTan2
Csc ArcCsc
Sec ArcSec
ArcCot
[EXAMPLE]
VAR
I : INTEGER;
R : REAL;
BEGIN
R := 1.0;
For i := 100 DownTo 0 Do
BEGIN
WriteLn( 'ArcCoth(',R:0:0,') = ',ArcCoth( R ) :8:4 );
R := R - 0.01;
END; { For i }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Power( Num : LONGINT;
Exponent : LONGINT ) : LONGINT;
[PARAMETERS]
Num Number to Raise to Power
Exponent Power to Raise Value by
[RETURNS]
Number Raised by a given Power
[DESCRIPTION]
Determines the Number Raised to a given Power. Return the result
as a Long Integer Value.
[SEE-ALSO]
PowerR
Root
RootR
[EXAMPLE]
VAR
Answer : REAL;
BEGIN
Answer := PowerR( 7, 2 ); { Answer = 49 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function PowerR( Num : REAL;
Exponent : REAL ) : REAL;
[PARAMETERS]
Num Number to Raise to a Power
Exponent Power to Raise Number by
[RETURNS]
Number Raised by a given Power
[DESCRIPTION]
Determines the Number Raised by a given Power. Returns the result
as a Floating Point Value.
[SEE-ALSO]
Power
Root
RootR
[EXAMPLE]
VAR
Answer : REAL;
BEGIN
Answer := PowerR( 7.0, 2.0 ); { Answer = 49.0 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Root( Num : LONGINT;
RootVal : LONGINT ) : LONGINT;
[PARAMETERS]
Num Number to get a Root from (Must be > 0 or RunTime Error!)
RootVal Root to apply to Number (can be any real number)
[RETURNS]
The Root Value of a given Number
[DESCRIPTION]
Computes the Root Value of a given Number. The result is returned
as a Long Integer Value.
NOTE: Be sure that "Num" is Zero (0) or greater as imaginary Roots
and use of other Complex Numbers will cause a Runtime Error in this
Function.
[SEE-ALSO]
Power
PowerR
RootR
[EXAMPLE]
VAR
Answer : LONGINT;
BEGIN
Answer := Root( 49, 2 ); { Answer = 7 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function RootR( Num : REAL;
RootVal : REAL ) : REAL;
[PARAMETERS]
Num Number to get a Root from (Must be > 0 or RunTime Error!)
RootVal Root to apply to Number (can be any real number)
[RETURNS]
The Root Value of a given Number
[DESCRIPTION]
Computes the Root Value of a given Number. The result is returned
as a Floating Point Value.
NOTE: Be sure that "Num" is Zero (0) or greater as imaginary Roots
and use of other Complex Numbers will cause a Runtime Error in this
Function.
[SEE-ALSO]
Power
PowerR
Root
[EXAMPLE]
VAR
Answer : REAL;
BEGIN
Answer := RootR( 49.0, 2.0 ); { Answer = 7.0 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Log( Num : REAL;
Base : REAL ) : REAL;
[PARAMETERS]
Num Number to determine a Base of
Base Base Value to use for Logarithm
[RETURNS]
Logarithm of a given Number.
[DESCRIPTION]
Computes a Logarithm of a given Number using a given Base.
To use "Natural" Logarithm use the Value from the Function E
as the Base.
The result is returned as a Floating Point Value.
[SEE-ALSO]
[EXAMPLE]
VAR
Answer : REAL;
BEGIN
Answer := Log( 32, 2 ); { Answer = 5.0 }
END;
──────────────────────────────────────────────────────────────────────────────
[Function]
Function FastHyp( XDist : REAL;
YDist : REAL ) : REAL;
[PARAMETERS]
XDist X Distance between Points
YDist Y Distance between Points
[RETURNS]
The Hypotenuse of the X and Y Distances
[DESCRIPTION]
Computes and returns the Hypotenuse of the X and Y Distances
from another Point. The main advantage of this routine is that
is does all the routines as simple Math functions thereby
reducing the computation time.
This method is useful in providing accept/reject distance tests
in 2D graphics. These are commonly used in providing "Gravity
Fields" or other proximity tests for circle or ellipse selection.
This form is commony employed in libraries offering a high-precision
hypot as the conventional form is prone to severe loss of accuracy.
Note that the code is symmetric about the axis x = y = 1 within the
first quadrant. Absolute value operation on the input arguments
allow for four-quadrant operation, yeilding isometric distance lines
of eight-fold symmetry.
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[Function]
Function FastHypR( XDist : REAL;
YDist : REAL ) : REAL;
[PARAMETERS]
XDist X Distance between Points
YDist Y Distance between Points
[RETURNS]
The Hypotenuse of the X and Y Distances
[DESCRIPTION]
Computes and returns the Hypotenuse of the X and Y Distances
from another Point. The main advantage of this routine is that
is does all the routines as simple Math functions thereby
reducing the computation time.
This method is useful in providing accept/reject distance tests
in 2D graphics. These are commonly used in providing "Gravity
Fields" or other proximity tests for circle or ellipse selection.
This form is commony employed in libraries offering a high-precision
hypot as the conventional form is prone to severe loss of accuracy.
Note that the code is symmetric about the axis x = y = 1 within the
first quadrant. Absolute value operation on the input arguments
allow for four-quadrant operation, yeilding isometric distance lines
of eight-fold symmetry.
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[Function]
Function Hypot( XDist : REAL;
YDist : REAL ) : REAL;
[PARAMETERS]
XDist X Distance between Points
YDist Y Distance between Points
[RETURNS]
The Hypotenuse of the X and Y Distances
[DESCRIPTION]
Computes and returns the Hypotenuse of the X and Y Distances
from another Point.
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function FastDist( X1 : LONGINT;
Y1 : LONGINT;
X2 : LONGINT;
Y2 : LONGINT ) : LONGINT;
[PARAMETERS]
X1 X Coordinate of 1st Point
Y1 Y Coordinate of 1st Point
X2 X Coordinate of 2nd Point
Y2 Y Coordinate of 2nd Point
[RETURNS]
The Distance between the 2 Points (the Hypotenuse)
[DESCRIPTION]
Computes and returns the distance between 2 points whose Coordinates
are provided.
[SEE-ALSO]
Hypot
[EXAMPLE]
BEGIN
WriteLn( 'Distance = ',Distance( 10,10, 20,20 ):8:4 );
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function DistanceXY( X1 : REAL;
Y1 : REAL;
X2 : REAL;
Y2 : REAL ) : REAL;
[PARAMETERS]
X1 X Coordinate of 1st Point
Y1 Y Coordinate of 1st Point
X2 X Coordinate of 2nd Point
Y2 Y Coordinate of 2nd Point
[RETURNS]
The Distance between the 2 Points (the Hypotenuse)
[DESCRIPTION]
Computes and returns the distance between 2 points whose Coordinates
are provided.
[SEE-ALSO]
Hypot
[EXAMPLE]
BEGIN
WriteLn( 'Distance = ',Distance( 10,10, 20,20 ):8:4 );
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Percent( Part : LONGINT;
Whole : LONGINT ) : REAL;
[PARAMETERS]
Part Portion of the Whole being Referenced
Whole Size representing 100% of Value
[RETURNS]
Percentage of 100% which Part represents
[DESCRIPTION]
Determines what percentage of the "Whole" Value the "Part" Value
represents.
[SEE-ALSO]
[EXAMPLE]
VAR
Answer : REAL;
BEGIN
Answer := Percent( 30.0, 60.0 ); { Answer = 50.0 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Min( A : LONGINT;
B : LONGINT ) : LONGINT;
[PARAMETERS]
A 1st Source Value
B 2nd Source Value
[RETURNS]
The Lesser of the two Values
[DESCRIPTION]
Returns the Lesser of the Two Values as a Long Integer Value.
[SEE-ALSO]
MinR
Max
MaxR
[EXAMPLE]
VAR
Answer : LONGINT;
BEGIN
Answer := Min( 5, 3 ); { Answer = 3 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function MinR( A : REAL;
B : REAL ) : REAL;
[PARAMETERS]
A 1st Source Value
B 2nd Source Value
[RETURNS]
The Lesser of the two Values
[DESCRIPTION]
Returns the Lesser of the Two Values as a Floating Point Value.
[SEE-ALSO]
Min
Max
MaxR
[EXAMPLE]
VAR
Answer : REAL;
BEGIN
Answer := MinR( 5.2, 3.6 ); { Answer := 3.6 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Max( A : LONGINT;
B : LONGINT ) : LONGINT;
[PARAMETERS]
A 1st Source Value
B 2nd Source Value
[RETURNS]
The Greater of the two Values
[DESCRIPTION]
Returns the Greater of the Two Values as a Long Integer Value.
[SEE-ALSO]
Min
MinR
MaxR
[EXAMPLE]
VAR
Answer : LONGINT;
BEGIN
Answer := Max( 5, 3 ); { Answer = 5 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function MaxR( A : REAL;
B : REAL ) : REAL;
[PARAMETERS]
A 1st Source Value
B 2nd Source Value
[RETURNS]
The Greater of the two Values
[DESCRIPTION]
Returns the Greater of the Two Values as a Floating Point Value.
[SEE-ALSO]
Min
MinR
Max
[EXAMPLE]
VAR
Answer : REAL;
BEGIN
Answer := MaxR( 5.2, 3.6 ); { Answer = 5.2 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Range( Num : LONGINT;
Low : LONGINT;
High : LONGINT ) : LONGINT;
[PARAMETERS]
Num Source Value to Range Check
Low Minimum Limit
High Maximum Limit
[RETURNS]
The Value Clipped by the Range
[DESCRIPTION]
Range Checks a Value and Clips it to within the given Minimum
and Maximum Range. Result is returned as a Long Integer Value.
[SEE-ALSO]
RangeR
Floor
FloorR
Ceiling
CeilingR
[EXAMPLE]
VAR
Answer : LONGINT;
BEGIN
Answer := RangeR( 43 ,40, 50 ); { Answer = 43 }
Answer := RangeR( 37 ,40, 50 ); { Answer = 40 }
Answer := RangeR( 73 ,40, 50 ); { Answer = 50 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function RangeR( Num : REAL;
Low : REAL;
High : REAL ) : REAL;
[PARAMETERS]
Num Source Value to Range Check
Low Minimum Limit
High Maximum Limit
[RETURNS]
The Value Clipped by the Range
[DESCRIPTION]
Range Checks a Value and Clips it to within the given Minimum
and Maximum Range. Result is returned as a Floating Point Value.
[SEE-ALSO]
Range
Floor
FloorR
Ceiling
CeilingR
[EXAMPLE]
VAR
Answer : REAL;
BEGIN
Answer := RangeR( 43.6 ,40.0, 50.0 ); { Answer = 43.6 }
Answer := RangeR( 37.2 ,40.0, 50.0 ); { Answer = 40.0 }
Answer := RangeR( 73.3 ,40.0, 50.0 ); { Answer = 50.0 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Floor( Num : LONGINT;
Low : LONGINT ) : LONGINT;
[PARAMETERS]
Num Source Value to Range Check
Low Minimum Limit
[RETURNS]
The Value Clipped by the Minimum Range
[DESCRIPTION]
Range Checks a Value and Clips it so it is at or above a given
Minimum Range. The result is returned as a Long Integer Value.
[SEE-ALSO]
Range
RangeR
FloorR
Ceiling
CeilingR
[EXAMPLE]
VAR
Answer : LONGINT;
BEGIN
Answer := Floor( 33, 25 ); { Answer = 33 }
Answer := Floor( 17, 25 ); { Answer = 25 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function FloorR( Num : REAL;
Low : REAL ) : REAL;
[PARAMETERS]
Num Source Value to Range Check
Low Minimum Limit
[RETURNS]
The Value Clipped by the Minimum Range
[DESCRIPTION]
Range Checks a Value and Clips it so it is at or above a given
Minimum Range. The result is returned as a Floating Point Value.
[SEE-ALSO]
Range
RangeR
Floor
Ceiling
CeilingR
[EXAMPLE]
VAR
Answer : REAL;
BEGIN
Answer := FloorR( 22.5, 20.0 ); { Answer = 22.5 }
Answer := FloorR( 17.5, 20.0 ); { Answer = 20.0 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Ceiling( Num : LONGINT;
High : LONGINT ) : LONGINT;
[PARAMETERS]
Num Source Value to Range Check
High Maximum Limit
[RETURNS]
The Value Clipped by the Maximum Range
[DESCRIPTION]
Range Checks a Value and Clips it so it is at or above a given
Maximum Range. The result is returned as a Long Integer Value.
[SEE-ALSO]
Range
RangeR
Floor
FloorR
CeilingR
[EXAMPLE]
VAR
Answer : LONGINT;
BEGIN
Answer := Ceiling( 32, 40 ); { Answer = 32 }
Answer := Ceiling( 45, 40 ); { Answer = 40 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function CeilingR( Num : REAL;
High : REAL ) : REAL;
[PARAMETERS]
Num Source Value to Range Check
High Maximum Limit
[RETURNS]
The Value Clipped by the Maximum Range
[DESCRIPTION]
Range Checks a Value and Clips it so it is at or above a given
Maximum Range. The result is returned as a Floating Point Value.
[SEE-ALSO]
Range
RangeR
Floor
FloorR
Ceiling
[EXAMPLE]
VAR
Answer : REAL;
BEGIN
Answer := Ceiling( 95.2, 100.0 ); { Answer := 95.2 }
Answer := Ceiling( 104.5, 100.0 ); { Answer := 100.0 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Sign( Num : LONGINT ) : INTEGER;
[PARAMETERS]
Num Source Value
[RETURNS]
The Value's Sign (+1 if >= 0, or -1 if < 0 )
[DESCRIPTION]
Determines the sign of the Source Value. If it is Greater or Equal
to Zero, then it is +1. If it is Less than Zero, then it is -1.
The result is returned as a Long Integer Value.
[SEE-ALSO]
[EXAMPLE]
VAR
Answer : INTEGER;
BEGIN
Answer := Sign( 100 ); { Answer = +1 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function SignR( Num : LONGINT ) : INTEGER;
[PARAMETERS]
Num Source Value
[RETURNS]
The Value's Sign (+1 if >= 0, or -1 if < 0 )
[DESCRIPTION]
Determines the sign of the Source Value. If it is Greater or Equal
to Zero, then it is +1. If it is Less than Zero, then it is -1.
The result is returned as a Floating Point Value.
[SEE-ALSO]
Sign
[EXAMPLE]
VAR
Answer : INTEGER;
BEGIN
Answer := SignR( -32.6 ); { Answer = -1 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function QuadraticPlus( A : LONGINT;
B : LONGINT;
C : LONGINT ) : REAL;
[PARAMETERS]
A 1st Polynomial Position Value
B 2nd Polynomial Position Value
C 3rd Polynomial Position Value
[RETURNS]
Positive Quadratic Solution in Terms of X
[DESCRIPTION]
Computes the Quadratic of y = Ax^2 + Bx + C in terms of X with
only the Positive Answer returned.
[SEE-ALSO]
QuadraticNeg
[EXAMPLE]
VAR
X : REAL;
BEGIN
X := QuadraticPlus( 2, 8, 4 ); { X = -0.5858 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function QuadraticNeg( A : LONGINT;
B : LONGINT;
C : LONGINT ) : REAL;
[PARAMETERS]
A 1st Polynomial Position Value
B 2nd Polynomial Position Value
C 3rd Polynomial Position Value
[RETURNS]
Negative Quadratic Solution in Terms of X
[DESCRIPTION]
Computes the Quadratic of y = Ax^2 + Bx + C in terms of X with
only the Negative Answer returned.
[SEE-ALSO]
QuadraticPlus
[EXAMPLE]
VAR
X : REAL;
BEGIN
X := QuadraticNeg( 2, 8, 4 ); { X = -3.4142}
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Factorial( N : BYTE ) : REAL;
[PARAMETERS]
N Natural Number to Factor
[RETURNS]
Factorial Product
[DESCRIPTION]
Returns the Factorial Product of a Number. N=33 is the Maximum
for real type answers.
[SEE-ALSO]
[EXAMPLE]
VAR
Answer : REAL;
BEGIN
Answer := Factorial( 2 ); { Answer = 2.0000 }
Answer := Factorial( 4 ); { Answer = 24.0000 }
Answer := Factorial( 6 ); { Answer = 720.0000 }
Answer := Factorial( 12 ); { Answer = 479001600.0000 }
Answer := Factorial( 36 ); { Answer = 1.0000 }
Answer := Factorial( 100 ); { Answer = 1.0000 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Permu( N : BYTE;
R : BYTE ) : REAL;
[PARAMETERS]
N Number of Objects to Use
R Use R at a Time (for each Permutation)
[RETURNS]
Permutation Product
[DESCRIPTION]
Returns the number of permutations of "N" Objects taken "R"
at a time, which means a listing or an arrangement of R of
the Objects in a definite order, where R <= N. The number
of such arrangements is denoted by P(n,r).
[SEE-ALSO]
Combo
[EXAMPLE]
VAR
Answer : REAL;
BEGIN
Answer := Permu( 12, 2 ); { Answer = 134 }
Answer := Permu( 12, 3 ); { Answer = 1340 }
Answer := Permu( 12, 4 ); { Answer = 11880 }
Answer := Permu( 12, 5 ); { Answer = 95040 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Combo( N : BYTE;
R : BYTE ) : REAL;
[PARAMETERS]
N Number of Objects to Use
R Use R at a Time (for each combination)
[RETURNS]
Combination Product
[DESCRIPTION]
Returns the selection or subset of "R" Objects from a set of
"N" Objects, where R <= N. The number of such combinations
is denoted C(n,r).
[SEE-ALSO]
Permu
[EXAMPLE]
VAR
Answer : REAL;
BEGIN
Answer := Combo( 12, 2 ); { Answer = 66 }
Answer := Combo( 12, 3 ); { Answer = 220 }
Answer := Combo( 12, 4 ); { Answer = 495 }
Answer := Combo( 12, 5 ); { Answer = 792 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Prime( N : LONGINT ) : BOOLEAN;
[PARAMETERS]
N Number to Check that it is a Prime Number
[RETURNS]
Whether or not this Number was a Prime Nmuber
[DESCRIPTION]
Determines if this number was a Prime Number and returns the result.
[SEE-ALSO]
[EXAMPLE]
BEGIN
WriteLn( 'Prime( 3)=',Prime( 3) ); { TRUE }
WriteLn( 'Prime( 6)=',Prime( 6) ); { FALSE }
WriteLn( 'Prime(15)=',Prime(15) ); { FALSE }
WriteLn( 'Prime(23)=',Prime(23) ); { TRUE }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function GCF( A : LONGINT;
B : LONGINT ) : LONGINT;
[PARAMETERS]
A 1st Source Number
B 2nd Source Number
[RETURNS]
The Greatest Common Factor of the two numbers.
[DESCRIPTION]
Determines the Greatest Common Factor between the two given
numbers.
[SEE-ALSO]
LCM
[EXAMPLE]
VAR
Answer : LONGINT;
BEGIN
Answer := GCF( 6, 9 );
{ Answer := 3 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function LCM( A : LONGINT;
B : LONGINT ) : LONGINT;
[PARAMETERS]
A 1st Source Number
B 2nd Source Number
[RETURNS]
The Least Common Multiple of the two numbers.
[DESCRIPTION]
Determines the Least Common Multiple between the two given
Numbers.
[SEE-ALSO]
GCF
[EXAMPLE]
VAR
Answer : LONGINT;
BEGIN
Answer := LCM( 36, 54 );
{ Answer = 108 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure LoadArrayR( VAR Arr : PArrayR;
Idx : WORD;
R : REAL );
[PARAMETERS]
Arr Pointer to Linear Data Array
Idx Number of Elements in the Data Array
R Value to set Element to
[RETURNS]
(Function : None)
(VAR : Pointer to Linear Data Array w/ Data Modified)
[DESCRIPTION]
Loads the Data Array's Indexed Element to the Provided Value
Use this Procedure to quickly Load the Data Array Values for the
Coordinate Record at a specific Index.
[SEE-ALSO]
LoadArrayRXY
[EXAMPLE]
VAR
Arr : PArrayR;
BEGIN
LoadArrayR( Arr, 3, 97.5 );
{ Element in "Arr" at Index 3 now equals 97.5 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure LoadArrayRXY( VAR Arr : PArray2R;
Idx : WORD;
X : REAL;
Y : REAL );
[PARAMETERS]
Arr Pointer to Linear Data Array or Coordinates
Idx Number of Elements in the Data Array
X Value to Set X-Element To
Y Value to Set Y-Element To
[RETURNS]
(Function : None)
(VAR : Pointer to Linear Data Array w/ Data Modified)
[DESCRIPTION]
Loads the Data Array's Indexed Elements (X & Y) to the Provided Values.
Use this Procedure to quickly Load the Data Array Values for the
Coordinate Record at a specific Index.
[SEE-ALSO]
LoadArrayR
[EXAMPLE]
VAR
Arr : PArray2R;
BEGIN
LoadArrayRXY( Arr, 5, 2.5, 3.7 );
{ Record in "Arr" at Index now contains X=2.5 and Y=3.7 }
END;
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure MeanStdDev( Arr : PArrayR; { Data Array }
Cnt : INTEGER; { Data Count }
VAR Mean : REAL; { Mean }
VAR StdDev : REAL ); { Standard Deviation }
[PARAMETERS]
Arr Pointer to Linear Data Array
Cnt Number of Elements in Linear Data Array
Mean VAR Returned Mean Value of Dispursion
StdDev VAR Returned Standard Deviation of Dispursion
[RETURNS]
(Function : None)
(VAR : [Mean] Returned Mean Value of Dispursion)
(VAR : [StdDev] Returned Standard Deviation of Dispursion)
[DESCRIPTION]
Takes a List of Values and determines what the Mean [Middle] Dispersion
Value is and what the Dispursion Deviation is.
[SEE-ALSO]
[EXAMPLE]
VAR
Arr : PArrayR;
Mean,
StdDev : REAL;
BEGIN
LoadArray( Arr, 1, 1 );
LoadArray( Arr, 2, 2 );
LoadArray( Arr, 3, 3 );
LoadArray( Arr, 4, 4 );
LoadArray( Arr, 5, 5 );
MeanStdDev( Arr, 5, Mean, StdDev );
{ Mean = 3.000, StdDev = 1.5811 }
END.
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Function Sigma( Arr : PArrayR;
Cnt : INTEGER ) : REAL;
[PARAMETERS]
Arr Pointer to Linear Data Array
Cnt Number of Elements in Data Array
[RETURNS]
The Sigma Summation of the Data Values
[DESCRIPTION]
Calculates the Sigma Summation of the Data Provided.
[SEE-ALSO]
[EXAMPLE]
──────────────────────────────────────────────────────────────────────────────
[FUNCTION]
Procedure LeastSqr( Arr : PArray2R; { Data Array }
Cnt : INTEGER; { Data Count }
VAR YInt : REAL; { Y-Intercept }
VAR Slope : REAL ); { Slope }
[PARAMETERS]
Arr Pointer to Linear Array of Point Coordinate Data
Cnt Number of Coordinates in Array
YInt VAR Returned Y-Intercept Solution
Slope VAR Returned Line Slope Solution
[RETURNS]
(Function : None)
(VAR : [YInt] Returned Y-Intercept Solution)
(VAR : [Slope] Returned Line Slope Solution)
[DESCRIPTION]
Does a Least Squares Line Fitting Algorithm on the Point Data
and determines the Line Solution's Y-Intercept and Slope (expressed
as a Tangent Value - ArcTan returns Angle).
To Construct resulting Line use the Algorithm
y = Slope * x + YInt;
[SEE-ALSO]
(None)
[EXAMPLES]
VAR
Arr : PArray2RA;
YInt,
Slope : REAL;
BEGIN
LoadArrayRXY( Arr, 1, 1, 2 );
LoadArrayRXY( Arr, 2, 2, 3 );
LoadArrayRXY( Arr, 3, 3, 4 );
LoadArrayRXY( Arr, 4, 4, 5 );
LoadArrayRXY( Arr, 5, 5, 6 );
LoadArrayRXY( Arr, 6, 6, 7 );
LeastSqr( Arr, 6, YInt, Slope );
{ YInt = 1.0, Slope = 1.0[Tan] (45deg) }
END;